package com.hong.chapter3;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * @Auther: Administrator
 * @Date: 2018/7/17 21:34
 * @Description: 自定义classLoader
 */
public class MyClassLoaderTest {
    public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
        MyClassLoader classLoader = new MyClassLoader("MyClassLoader");
        Class<?> aClass = classLoader.loadClass("com.hong.chapter3.classloader1");
        System.out.println(aClass);
        System.out.println(aClass.getClassLoader());
        Object object = aClass.newInstance();
        Method method = aClass.getMethod("hello", new Class<?>[]{});
        Object result = method.invoke(object, new Object[]{});
        System.out.println(result);
    }
}
